#include <glib.h>

static void _queue_foreach_func(gpointer data, gpointer       user_data)
{
    g_print("user_data:%s, data:%d \n", (gchar *)user_data, GPOINTER_TO_INT(data));
}

gint main(gint argc, gchar **argv)
{
    GQueue *q = NULL;
    gboolean empty = FALSE;

    q = g_queue_new();

    g_queue_push_tail(q, GINT_TO_POINTER(10));
    g_queue_push_tail(q, GINT_TO_POINTER(15));
    g_queue_push_tail(q, GINT_TO_POINTER(20));
    // result: 10-15-20

    g_queue_foreach(q, _queue_foreach_func, "Queue");

    // clear
    g_queue_clear(q);

    empty = g_queue_is_empty(q);
    g_print( "empty:%s \n", empty ? "TRUE" : "FALSE" );

    g_queue_free(q);

    return 0;
}